#include <QSqlDatabase>
#include "udatabase.h"

QSqlDatabase& UDataBase::BooksDatabase()
{
	static QSqlDatabase instance;
	static bool s_once = false;
	if (!s_once)
	{
		s_once = true;
		instance = QSqlDatabase::addDatabase("QSQLITE", "CONNECTION_BOOKS");
		instance.setDatabaseName("BooksDatabase.db");
		instance.open();
	}
	return instance;
}

QSqlDatabase& UDataBase::BookshelfsDatabase()
{
	static QSqlDatabase instance;
	static bool s_once = false;
	if (!s_once)
	{
		s_once = true;
		instance = QSqlDatabase::addDatabase("QSQLITE", "CONNECTION_BOOKSHELFS");
		instance.setDatabaseName("BookshelfsDatabase.db");
		instance.open();
	}
	return instance;
}

QSqlDatabase& UDataBase::LibraryDatabase()
{
	static QSqlDatabase instance;
	static bool s_once = false;
	if (!s_once)
	{
		s_once = true;
		instance = QSqlDatabase::addDatabase("QSQLITE", "CONNECTION_LIBRARY");
		instance.setDatabaseName("LibraryDatabase.db");
		instance.open();
	}
	return instance;
}
